package com.example.springbootlearn.web.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.example.springbootlearn.data.pojo.User;
import com.example.springbootlearn.service.UserService;

@RestController
@RequestMapping("user")
public class UserController {
	private static final Logger LOGGER = LoggerFactory.getLogger(UserController.class);
	@Autowired
	UserService userService;

	@GetMapping
	public List<User> getAllUser() {
		LOGGER.info("get all user request comming");
		return userService.queryAll();
	}

	@GetMapping("{id}")
	public Map<String, String> getOneUser(@PathVariable String id) {
		Map<String, String> result = new HashMap<>();
		result.put("id", id);
		result.put("sex", "F");
		return result;
	}

	@PostMapping()
	public boolean saveUser(@RequestBody Map<String, String> request) {

		return true;
	}

}
